package testcases;

import java.util.ArrayList;

import junit.framework.TestCase;

import org.junit.Test;

import sanitycheck.SolutionEnumeration;
import def.Event;
import def.Protein;
import def.TSpan;


public class SolEnuTest extends TestCase {
	
	@Test public void testGenerateEvents(){
		ArrayList<ArrayList<Event>> solutions = new ArrayList<ArrayList<Event>>();
		ArrayList<TSpan> potentialParents = new ArrayList<TSpan>(), onlyChildren  = new ArrayList<TSpan>();
		int np = 3, nc = 4, npt = 3;
		String[] parentStrings = new String[] {"using", "essential", "hindrance"};
		for (int i = 0; i < np; i++){
			TSpan ts = new TSpan();
//			ts.text = "p"+i;
			ts.text = parentStrings[i];
			potentialParents.add(ts);
		}
		for (int i = 0; i < nc; i++){
			TSpan ts = new TSpan();
			ts.text = "c"+i;
			onlyChildren.add(ts);
		}
		long startTime = System.currentTimeMillis();
		ArrayList<Protein> proteins = new ArrayList<Protein>();
		for (int i = 0; i < npt; i++){
			Protein p = new Protein();
			TSpan ts = new TSpan();
			ts.text = "pt"+i;
			p.tspan = ts;
			proteins.add(p);
		}
//		SolutionEnumeration.generateEvents(potentialParents, onlyChildren, proteins, 0, 0, 0, 0, new ArrayList<Event>(), solutions);
		long endTime = System.currentTimeMillis();
		System.err.println((endTime - startTime)+"   "+SolutionEnumeration.debugCounter);
	}
	
	
	private int choose(int n, int i){
		//choose i from n
		if ( i < n/2+1){
			int ans = 1;
			for ( int j = 0; j < i; j++){
				ans*=(n-j);
			}
			for ( int j = 0; j < i; j++){
				ans/=(1+j);
			}
			return ans;
		}
		else{
			return choose(n, n-i);
		}
	}
	@Test public void testLinkProtein(){
//		ArrayList<Event> events = new ArrayList<Event>();
//		events.add(new Event());
//		ArrayList<Protein> proteins = new ArrayList<Protein>();
//		int num = 6;
//		for (int i =0 ; i < num; i++){
//			proteins.add(new Protein());
//		}
//		int ans = 0;
//		if (num <= BioNLPSettings.MAX_CHOOSE){
//			ans = (1<< num) -1;
//		}
//		else{
//			for (int i =1 ; i <= BioNLPSettings.MAX_CHOOSE; i++){
//				ans += choose(num, i);
//				System.err.println(ans);
//			}	
//		}
//		
//		try {
//			File file = File.createTempFile("bionlp", null);
//			file.deleteOnExit();
//			System.setOut(new PrintStream(file));
//			long startTime = System.currentTimeMillis();
//			SolutionEnumeration.linkEventProtein(events,
//					new ArrayList<TSpan>(), proteins, 0,
//					new ArrayList<ArrayList<Event>> ());
//			int sub = FileUtil.getTextFromFile(file.getAbsolutePath()).split("\n").length;
//			long endTime = System.currentTimeMillis();
//			System.err.println((endTime-startTime));
//			System.err.println(sub+"  "+ ans);
//			assertEquals(sub, ans);
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
	}
}
